﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using FineUI;
using SDLITS.Model;
using SDLITS.Common;
using System.Data;
using System.Data.SqlClient;

namespace SDLITS.Web.SystemManage
{
    public partial class CardModifyManage : CommonBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        public void DataBindToGridview()
        {
            SqlParameter[] sp2 = new SqlParameter[]{
                    new SqlParameter("@IDNumber",txtIDNumber.Text),
                    new SqlParameter("@CarNo",txtCarNo.Text),
                    new SqlParameter("@Name",txtName.Text),
                    new SqlParameter("@CarEnginNo", txtCarEnginNo.Text),
                    new SqlParameter("@CarIDNo",txtCarIDNo.Text),
                    new SqlParameter("@MemCardNo",txtMemCardNo.Text),
                    new SqlParameter("@SPAction","SelectByDateRange")
                };
            Grid1.Hidden = false;
            DataSet ds = SDDbSession.Default.FromProc("TableMemberInfo").AddParameter(sp2).ToDataSet();
            Grid1.DataSource = ds.Tables[0];
            Grid1.DataBind();

        }
        protected void btnSaveRefresh_Click(object sender, EventArgs e)
        {
            if (IsValids())
            {
                DataBindToGridview();
                return;
            }

            Alert.Show("至少输入一个查询条件！");
        }
        private bool IsValids()
        {
            if (string.IsNullOrEmpty(txtIDNumber.Text.Trim()) && string.IsNullOrEmpty(txtMemCardNo.Text.Trim()) &&
                string.IsNullOrEmpty(txtName.Text.Trim()) && string.IsNullOrEmpty(txtCarEnginNo.Text.Trim()) &&
                string.IsNullOrEmpty(txtCarIDNo.Text.Trim()) && string.IsNullOrEmpty(txtCarNo.Text.Trim()))
            {
                return false;
            }
            return true;
        }

        protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
        {
            Grid1.PageIndex = e.NewPageIndex;
            DataBindToGridview();
        }
    }
}